package com.hiwan.system.pojo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class OrgCacheInfo implements Serializable {
	private static final long serialVersionUID = -1472848274970288365L;

	/**
	 * 机构ID
	 */
	private String orgId;

	/**
	 * 机构名称
	 */
	private String orgName;
	
	/**
	 * 机构等级
	 */
	private String orgLevel;
	
	/**
	 * 上级机构
	 */
	private String parentId;
	
	/**
	 * 机构类型（3-普通网点，2-营业部，1-管理机构）
	 */

	private String orgType;
	
	/**
	 * 机构层级(树形结构层级)
	 */
	private String treeLevel;
	
	
	/**
	 * 子机构列表
	 */
	private List<String> childOrgList = new ArrayList<String>();
	/**
	 * 统计归属子机构
	 */
	private List<String> childOrgList4Report = new ArrayList<String>();
	
	/**
	 * 子部门列表
	 */
	private List<String> childDeptList = new ArrayList<String>();
	
	/**
	 * 统计归属子部门
	 */
	private List<String> childDeptList4Report = new ArrayList<String>();

	
	/**
	 * 统计归属机构
	 */
	private String toOrgId;
	/**
	 * 是否有子机构
	 */
	private String hasChild;
	/**
	 * 是否有子部门
	 */
	private String hasDept;
	/**
	 * 是否有员工
	 */
	private String hasUser;
	/**
	 * 机构状态
	 */
	private String status;
	/**
	 * 层次序号
	 */
	private String levelOrder;
	/**
	 * 机构员工总人数
	 * 
	 */
	private String orgUserNum;
	
	public String getToOrgId() {
		return toOrgId;
	}
	
	public void setToOrgId(String toOrgId) {
		this.toOrgId = toOrgId;
	}
	
	
	static public OrgCacheInfo cast2OrgCache(OrgInfo orgInfo, List<OrgInfo> childOrgList, List<DeptInfo> childDeptList) {
//		if (orgInfo == null) {
//			return null;
//		}
//		OrgCacheInfo orgCacheInfo = new OrgCacheInfo();
//		orgCacheInfo.setOrgId(orgInfo.getOrgId());
//		orgCacheInfo.setOrgName(orgInfo.getOrgName());
//		orgCacheInfo.setParentId(orgInfo.getParentId());
//		orgCacheInfo.setOrgLevel(orgInfo.getOrgLevel());
//		orgCacheInfo.setTreeLevel(orgInfo.getTreeLevel());
//		orgCacheInfo.setOrgType(orgInfo.getOrgType());
//		if(childOrgList == null) {
//			childOrgList = new ArrayList<OrgInfo>();
//		}
//		orgCacheInfo.setChildOrgList(childOrgList);
//		if(childDeptList == null) {
//			childDeptList = new ArrayList<DeptInfo>();
//		}
//		orgCacheInfo.setChildDeptList(childDeptList);
		return cast2OrgCache(orgInfo, childOrgList, childDeptList, null, null);
	}
	
	static public OrgCacheInfo cast2OrgCache(OrgInfo orgInfo, 
			List<OrgInfo> childOrgList, List<DeptInfo> childDeptList,
			List<OrgInfo> childOrgList4Report, List<DeptInfo> childDeptList4Report) {
		if (orgInfo == null) {
			return null;
		}
		OrgCacheInfo orgCacheInfo = new OrgCacheInfo();
		orgCacheInfo.setOrgId(orgInfo.getOrgId());
		orgCacheInfo.setOrgName(orgInfo.getOrgName());
		orgCacheInfo.setParentId(orgInfo.getParentId());
		orgCacheInfo.setOrgLevel(orgInfo.getOrgLevel());
		orgCacheInfo.setTreeLevel(orgInfo.getTreeLevel());
		orgCacheInfo.setOrgType(orgInfo.getOrgType());
		orgCacheInfo.setToOrgId(orgInfo.getToOrgId());
		orgCacheInfo.setHasChild(orgInfo.getHasChild());
		orgCacheInfo.setHasDept(orgInfo.getHasDept());
		orgCacheInfo.setHasUser(orgInfo.getHasUser());
		orgCacheInfo.setStatus(orgInfo.getStatus());
		orgCacheInfo.setOrgUserNum(orgInfo.getOrgUserNum());
		orgCacheInfo.setChildDeptList4Report(childDeptList4Report);
		orgCacheInfo.setLevelOrder(orgInfo.getLevelOrder());
		if (childOrgList == null) {
			childOrgList = new ArrayList<OrgInfo>();
		}
		orgCacheInfo.setChildOrgList(childOrgList);
		if(childDeptList == null) {
			childDeptList = new ArrayList<DeptInfo>();
		}
		orgCacheInfo.setChildDeptList(childDeptList);
		if(childOrgList4Report == null) {
			childOrgList4Report = new ArrayList<OrgInfo>();
		}
		orgCacheInfo.setChildOrgList4Report(childOrgList4Report);
		
		return orgCacheInfo;
	}

	public List<String> getChildOrgList4Report() {
		return childOrgList4Report;
	}
	
	public void setChildOrgList4Report(List<OrgInfo> childOrgList4Report) {
		this.childOrgList4Report.clear();
		for(OrgInfo info : childOrgList4Report){
			this.childOrgList4Report.add(info.getOrgId());
		}
	}
	
	public String getOrgType() {
		return orgType;
	}

	public void setOrgType(String orgType) {
		this.orgType = orgType;
	}

	public String getOrgId() {
		return orgId;
	}

	public void setOrgId(String orgId) {
		this.orgId = orgId;
	}

	public String getOrgName() {
		return orgName;
	}

	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}

	public String getParentId() {
		return parentId;
	}

	public String getOrgLevel() {
		return orgLevel;
	}


	public void setOrgLevel(String orgLevel) {
		this.orgLevel = orgLevel;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public List<String> getChildOrgList() {
		return childOrgList;
	}

	public void setChildOrgList(List<OrgInfo> childOrgList) {
		this.childOrgList.clear();
		for(OrgInfo info : childOrgList){
			this.childOrgList.add(info.getOrgId());
		}
	}
	public List<String> getChildDeptList() {
		return childDeptList;
	}

	public void setChildDeptList(List<DeptInfo> childDeptList) {
		this.childDeptList.clear();
		for(DeptInfo info : childDeptList){
			this.childDeptList.add(info.getDeptId());
		}
	}
	public List<String> getChildDeptList4Report() {
		return childDeptList4Report;
	}

	public void setChildDeptList4Report(List<DeptInfo> childDeptList4Report) {
		this.childDeptList4Report.clear();
		for(DeptInfo info : childDeptList4Report){
			this.childDeptList4Report.add(info.getDeptId());
		}
	}

	public String getTreeLevel() {
		return treeLevel;
	}



	public void setTreeLevel(String treeLevel) {
		this.treeLevel = treeLevel;
	}

	public String getHasChild() {
		return hasChild;
	}

	public void setHasChild(String hasChild) {
		this.hasChild = hasChild;
	}

	public String getHasDept() {
		return hasDept;
	}

	public void setHasDept(String hasDept) {
		this.hasDept = hasDept;
	}

	public String getHasUser() {
		return hasUser;
	}

	public void setHasUser(String hasUser) {
		this.hasUser = hasUser;
	}
	

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}
	

	public String getLevelOrder() {
		return levelOrder;
	}

	public void setLevelOrder(String levelOrder) {
		this.levelOrder = levelOrder;
	}

	@Override
	public String toString() {
		return "OrgCacheInfo [orgId=" + orgId + ", orgName=" + orgName
				+ ",orgUserNum=" + orgUserNum +", orgLevel=" + orgLevel + ", parentId=" + parentId
				+ ", orgType=" + orgType + ", treeLevel=" + treeLevel
				+ ", childOrgList=" + childOrgList + ", childDeptList="
				+ childDeptList + ", childOrgList4Report="
				+ childOrgList4Report + ", toOrgId=" + toOrgId + "]";
	}

	public String getOrgUserNum() {
		return orgUserNum;
	}

	public void setOrgUserNum(String orgUserNum) {
		this.orgUserNum = orgUserNum;
	}
}
